﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace Lonewolf.Entity
{
    /// <summary>
    /// 泛型实体基类
    /// </summary>
    /// <typeparam name="TPrimaryKey">主键类型</typeparam>
    public abstract class BaseEntity<TPrimaryKey>
    {
        /// <summary>
        /// 主键
        /// </summary>
        [Key]
        [MaxLength(128)]
        public virtual TPrimaryKey Id { get; set; }
        /// <summary>
        /// 是否删除 - 伪删除
        /// </summary>
        public bool? IsDelete { get; set; } = false;
        /// <summary>
        /// 伪删除时间
        /// </summary>
        public DateTime? IsDeleteTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 最后变化时间
        /// </summary>
        public DateTime LastChangeTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 创建时间 - 默认当前时间
        /// </summary>
        public DateTime? CreateTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 创建人
        /// </summary>
        [MaxLength(128)]
        public string CreateUser { get; set; }
    }

    /// <summary>
    /// 定义默认主键类型为string的实体基类
    /// </summary>
    public abstract class BaseEntity : BaseEntity<string>
    {

    }
}
